package com.zretc.controller;

import com.github.pagehelper.PageInfo;
import com.zretc.entity.Auditoriums;
import com.zretc.entity.FilmType;
import com.zretc.entity.Sales;
import com.zretc.entity.Totals;
import com.zretc.service.SalesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("back")
public class BackSaleDataController {

    @Autowired
    private SalesService salesService;

    @RequestMapping("/saleData")
    @ResponseBody
    public PageInfo<Sales> getdate( @RequestParam("page") String page,
                                    @RequestParam("limit") String limit,
                          String filmName,
                           String screeningStartTime1,
                             String screeningStartTime2,
                          String auditoriumsName){

        Map<String,String> map =new HashMap<>();
        map.put("pageNum",page);
        map.put("pageSize",limit);
        map.put("filmName",filmName);
        map.put("screeningStartTime1",screeningStartTime1);
        map.put("screeningStartTime2",screeningStartTime2);
        map.put("auditoriumsName",auditoriumsName);

        PageInfo<Sales> companyByPage = salesService.getCompanyByPage(map);

        return companyByPage;
    }


    @GetMapping("/saleData/today")
    @ResponseBody
    public List<Sales> getByToday(){
        List<Sales> bytoday = salesService.getBytoday();
        return bytoday;
    }

    @GetMapping("/saleData1")
    @ResponseBody
    public  List<Totals> getByYear(){
        List<Totals> byYear = salesService.getByYear();
        return byYear;
    }


    @GetMapping("/saleData2/{years}")
    @ResponseBody
    public  List<Totals> getByMouth(@PathVariable(value ="years") String years){
        List<Totals> byMouth = salesService.getByMouth(years);
        return byMouth;
    }

    @GetMapping("/saleData3/{years}/{months}")
    @ResponseBody
    public  List<Totals> getByMouth(@PathVariable(value ="years") String years,
                                    @PathVariable(value ="months") String months){
        List<Totals> byDay = salesService.getByDay(years, months);
        return byDay;
    }

    @ResponseBody
    @GetMapping("/saleData4")
    public Map<String,Object> get(){
        Map<String, Object> map = salesService.get();
        return map;
    }

    @ResponseBody
    @GetMapping("/saleData5")
    public List<Auditoriums> getAllType(){
        List<Auditoriums> allAuditoriums = salesService.findAllAuditoriums();
        return allAuditoriums;
    }

}
